package com.git.bds.mr.doctor.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.git.bds.mr.doctor.convert.DoctorConvert;
import com.git.bds.mr.doctor.model.domain.Doctor;
import com.git.bds.mr.doctor.model.vo.DoctorInfoVO;
import com.git.bds.mr.doctor.service.DoctorService;
import com.git.bds.mr.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 医生信息表 前端控制器
 * </p>
 *
 * @author 成大事
 * @since 2022-09-19 16:41:33
 */
@Api(tags = "医生 管理")
@Slf4j
@Validated
@RestController
@RequestMapping("/doctor")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class DoctorController {

    private final DoctorService doctorService;

    @PostMapping("/getSelfInfo")
    @ApiOperation("医生获取自己详细信息")
    public R<DoctorInfoVO> getSelfInfo(){
        Doctor doctor = doctorService.getById(StpUtil.getLoginIdAsLong());
        return R.ok(DoctorConvert.INSTANCE.toDoctorVO(doctor));
    }

}
